package com.demo.enumdemo;

/**
 * @author xiangty
 */
class Color {
	static Color RED = new Color("红色");
	static Color GREEN = new Color("绿色");
	static Color BLUE = new Color("蓝色");

	public Color(String name) {
		this.name = name;
	}

	private String name;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static Color getInstance(int i) {
		switch (i) {
			case 1: {
				return RED;
			}
			case 2: {
				return GREEN;
			}
			case 3: {
				return BLUE;
			}
			default: {
				return null;
			}
		}
	}

}

public class ColorDemo {
	public static void main(String[] args){
		Color c1 = Color.RED;
		System.out.println(c1.getName());
		Color c2 = Color.getInstance(3);
		System.out.println(c2.getName());
	}
}
